home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / DivX / VFW4048src / src / dec_engine.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-18  |  4.3 KB  |  130 lines

  1.  
  2. /**************************************************************************
  3.  *                                                                        *
  4.  * This code is developed by Adam Li.  This software is an                *
  5.  * implementation of a part of one or more MPEG-4 Video tools as          *
  6.  * specified in ISO/IEC 14496-2 standard.  Those intending to use this    *
  7.  * software module in hardware or software products are advised that its  *
  8.  * use may infringe existing patents or copyrights, and any such use      *
  9.  * would be at such party's own risk.  The original developer of this     *
  10.  * software module and his/her company, and subsequent editors and their  *
  11.  * companies (including Project Mayo), will have no liability for use of  *
  12.  * this software or modifications or derivatives thereof.                 *
  13.  *                                                                        *
  14.  * Project Mayo gives users of the Codec a license to this software       *
  15.  * module or modifications thereof for use in hardware or software        *
  16.  * products claiming conformance to the MPEG-4 Video Standard as          *
  17.  * described in the Open DivX license.                                    *
  18.  *                                                                        *
  19.  * The complete Open DivX license can be found at                         *
  20.  * http://www.projectmayo.com/opendivx/license.php .                      *
  21.  *                                                                        *
  22.  **************************************************************************/
  23.  
  24. /************************************************************************
  25.  *
  26.  *  dec_engine.cpp, Decoder Engines
  27.  *
  28.  *  Copyright (C) 2000  DivX Networks
  29.  * 
  30.  *  Adam Li
  31.  *  Andrea Graziani
  32.  *
  33.  *  DivX Advance Research Center <darc@projectmayo.com>
  34.  *
  35.  ************************************************************************/
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39.  
  40. #include "stdafx.h"
  41. #include "codec.h"
  42. #include "decore.h"
  43.  
  44. long codec::decBegin(LPARAM lParam1, LPARAM lParam2)
  45. {
  46.     int x_dim, y_dim, size;
  47.  
  48.     BITMAPINFO *lpbiInput, *lpbiOutput;
  49.     BITMAPV4HEADER *infohdr_i;
  50.     DEC_PARAM dec_param;
  51.     DEC_SET dec_set;
  52.  
  53.     lpbiInput = (BITMAPINFO *)lParam1;
  54.     lpbiOutput = (BITMAPINFO *)lParam2;
  55.  
  56.     infohdr_i = (BITMAPV4HEADER *)&(lpbiInput->bmiHeader);
  57.     x_dim = infohdr_i->bV4Width;
  58.     y_dim = infohdr_i->bV4Height;
  59.     size = x_dim * y_dim;
  60.     dec_param.x_dim = x_dim;
  61.     dec_param.y_dim = y_dim;
  62.     dec_param.color_depth = lpbiOutput->bmiHeader.biBitCount;
  63.     
  64.     decore((long) this, DEC_OPT_INIT, &dec_param, NULL);
  65.  
  66.     // The postprocessing of the decore can be hard coded here for now.
  67.     // The filter that produces message will be implemented later.
  68.  
  69.     // postprcc_level =  0      ---->  no post processing
  70.     // postproc_level =  1 ~  9 ---->  horizontal deblocking only
  71.     // postproc_level = 10 ~ 19 ---->  hor. + ver. deblocking
  72.     // postproc_level = 20 ~ 29 ---->  full deblocking + deringing
  73.     // postproc_level = 30 ~ 39 ---->  above + deblocking chroma hor.
  74.     // postproc_level = 40 ~ 49 ---->  above + deblocking chroma ver.
  75.     // postproc_level = 50 ~ 59 ---->  above + deringing chroma
  76.  
  77.     dec_set.postproc_level = 0;
  78.  
  79.     decore((long) this, DEC_OPT_SETPP, &dec_set, NULL);
  80.  
  81.     return ICERR_OK;
  82. }
  83.  
  84. long codec::decEnd(LPARAM lParam1, LPARAM lParam2)
  85. {
  86.     decore((long) this, DEC_OPT_RELEASE, NULL, NULL);
  87.  
  88.     return ICERR_OK;
  89. }
  90.  
  91. long codec::decDecode(LPARAM lParam1, LPARAM lParam2)
  92. {
  93.     ICDECOMPRESS *icc = (ICDECOMPRESS *)lParam1;
  94.     ICOPEN *ico = (ICOPEN *)lParam2;
  95.  
  96.     DWORD flags = icc->dwFlags;
  97.  
  98.     BITMAPV4HEADER *lpbihdr_i, *lpbihdr_o;
  99.     DEC_FRAME dec_frame;
  100.  
  101.     lpbihdr_i = (BITMAPV4HEADER *)icc->lpbiInput;
  102.     lpbihdr_o = (BITMAPV4HEADER *)icc->lpbiOutput;
  103.  
  104.     lpbihdr_o->bV4V4Compression = BI_RGB;
  105.  
  106.     dec_frame.length = icc->lpbiInput->biSizeImage;
  107.     dec_frame.bitstream = icc->lpInput;
  108.     dec_frame.bmp = icc->lpOutput;
  109.  
  110.     if ((flags & ICDECOMPRESS_HURRYUP) | (flags & ICDECOMPRESS_UPDATE)) {
  111.         dec_frame.render_flag = 0;
  112.     }
  113.     else {
  114.         dec_frame.render_flag = 1;
  115.     }
  116.  
  117.     decore((long) this, 0, &dec_frame, NULL);
  118.  
  119.     return ICERR_OK;
  120. }
  121.  
  122. long codec::decSetPostProcessing(LPARAM lParam1, LPARAM lParam2)
  123. {
  124.     DEC_SET *dec_set = (DEC_SET *)lParam1;
  125.  
  126.     decore((long) this, DEC_OPT_SETPP, dec_set, NULL);
  127.  
  128.     return ICERR_OK;
  129. }
  130.